package com.aurora.CETManagementSystem.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.aurora.CETManagementSystem.utils.ResultInquiryUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * 四六级成绩查询Controller
 *
 */
@Controller
public class ResultInquiryController {


    /*
    * 跳转到分数查询页面
    * @param ik  准考证号
    *
    * */
    @RequestMapping("/student/queryScore")
    public String toqueryScore(String ik, Model model, HttpSession session, HttpServletResponse response){
        ik = "9210331902";
        String verificationCode = ResultInquiryUtils.getVerificationCode(ik, response);
        model.addAttribute("vcode","data:image/jpg;base64,"+verificationCode);
        return "student/queryScore";
    }



    /**
     * 获取考试成绩接口
     *
     * @param ticketNumber     准考证号
     * @param name             姓名
     * @param verificationCode 验证码
     * @param request          请求头
     * @param response
     * @return
     */
    @RequestMapping("/student/resultInquiry")
    @ResponseBody
    public Map<String, Object> resultInquiry(String ticketNumber, String name, String verificationCode, HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> map = ResultInquiryUtils.resultInquiry(ticketNumber, name, verificationCode, request);
        return map;
    }
}
